package routes

import (
	"github.com/gin-gonic/gin"
	"github.com/jassue/jassue-gin/app/controllers/app"
	"github.com/jassue/jassue-gin/app/middleware"
	"github.com/jassue/jassue-gin/app/services"
)

func SetApiGroupRoutes(router *gin.RouterGroup) {
	//router.POST("/auth/register", app.Register)
	router.POST("/auth/login", app.Login)

	authRouter := router.Group("").Use(middleware.JWTAuth(services.AppGuardName), middleware.Auth())
	{
		//用户信息
		authRouter.POST("/auth/info", app.Info)

		authRouter.POST("/auth/refresh", app.Refresh)
		authRouter.POST("/auth/logout", app.Logout)
		//authRouter.POST("/image_upload", common.ImageUpload)

		//用户管理
		authRouter.POST("/user/add", app.AddUer)
		authRouter.POST("/user/edit", app.EditUer)
		authRouter.POST("/user/editUserstatus", app.EditUserStatus)
		authRouter.POST("/user/getUserList", app.GetUserList)

		//用户组管理  addGroup SaveRoleUsers getGroupList
		authRouter.POST("/role/addRole", app.AddRole)
		authRouter.POST("/role/editRole", app.EditRole)
		authRouter.POST("/role/getRoleList", app.GetRoleLIst)
		authRouter.POST("/role/delRole", app.DelRole)

		//获取组内用户
		authRouter.POST("/role/getRoleUsers", app.GetRoleUsers)
		//获取全部用户
		authRouter.POST("/role/getAllUsers", app.GetAllUsers)
		//组内保存用户 添加用户或删除用户
		authRouter.POST("/role/saveRoleUsers", app.SaveRoleUsers)

		//菜单管理
		authRouter.POST("/menu/add", app.AddMenu)
		authRouter.POST("/menu/edit", app.EditMenu)
		authRouter.POST("/menu/setMenuSort", app.SetMenuSort)
		authRouter.POST("/menu/del", app.DelMenu)

		//所有菜单列表 菜单和按钮 树形结构转为平铺结构
		authRouter.POST("/menu/getMenuList", app.GetMenuList)

		//用户菜单列表 getmenu 不包含按钮
		authRouter.POST("/menu/getmenu", app.Getmenu)

		//获取用户所有按钮权限接口
		authRouter.POST("/menu/getButtonPermissions", app.GetButtonPermissions)

	}

}
